Skip to content

build: replace isort with ruff I rules#38227

Open
feanil wants to merge 5 commits intomasterfrom
feanil/fix_isort
Open

build: replace isort with ruff I rules#38227
feanil wants to merge 5 commits intomasterfrom
feanil/fix_isort

Conversation

@feanil
Copy link
Copy Markdown
Contributor

@feanil feanil commented Mar 27, 2026

Summary

Replaces the standalone isort tool with ruff's built-in I (isort) rules. Ruff's isort is compatible with—but not identical to—standalone isort, so this PR also normalizes the codebase before the switch.

Commits:

  • chore: Run isort . before switching to ruff — one final isort pass against the latest codebase to minimize the diff from the ruff-style changes that follow
  • build: Replace isort with ruff — drops isort from requirements/edx/testing.in, removes [tool.isort] from pyproject.toml, adds "I" to ruff's select list
  • fix: replace isort pragmas with ruff-equivalent noqa suppressions — converts # isort:skip / # isort:skip_file to # noqa: I001; preserves star-import ordering in Django settings files where import order is semantically significant
  • fix: apply ruff isort auto-fixes — runs ruff check --select I --fix to apply the ~765 mechanical differences between isort and ruff style (trailing commas on multi-line imports, backslash → parentheses continuations)
  • fix: add pylint inline disables broken by ruff import expansion — when ruff expands single-line imports to multi-line, inline # pylint: disable comments move to the item line where pylint can't see them; this commit moves them to a line above the from statement

🤖 Generated with Claude Code

@feanil feanil force-pushed the feanil/fix_isort branch 2 times, most recently from 592880d to 987a605 Compare March 30, 2026 19:02
@feanil feanil force-pushed the feanil/fix_isort branch 4 times, most recently from fbe3fa4 to 8891941 Compare April 3, 2026 17:20
feanil and others added 2 commits April 3, 2026 15:10
This is a preparatory commit so that switching from isort to ruff (which
uses a compatible but not identical sort order) results in a minimal diff
in the follow-up commit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Drop the direct isort requirement and migrate the isort config to ruff
config.
@feanil feanil force-pushed the feanil/fix_isort branch 2 times, most recently from 2318e2f to 7d9d2b7 Compare April 3, 2026 19:54
feanil and others added 2 commits April 3, 2026 15:55
isort:skip_file and isort:skip pragmas are not respected by ruff.
Replace them with ruff equivalents:
- File-level: # ruff: noqa: I001 (cms/__init__.py, cms/wsgi.py,
  openedx/core/lib/safe_lxml/etree.py, cms/conftest.py)
- Line-level: # noqa: I001 (manage.py, cms/urls.py)

We also added some suppressions to settings file where the wildcard
import and other import ordering is important.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Mechanical changes produced by `ruff check --select I --fix .`:
- adds trailing commas to multi-line import groups
- converts backslash line continuations to parentheses

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@feanil feanil force-pushed the feanil/fix_isort branch from 7d9d2b7 to 1cdcb64 Compare April 3, 2026 19:56
When ruff auto-fixes expand single-line imports to multi-line (adding
parentheses and trailing commas), inline pylint disables that were on
the original line end up on the last item inside the parens rather than
on the `from` statement. Pylint does not recognize these as suppressing
the warning on the import.

Affected issues: unused-import, reimported, redefined-outer-name,
useless-import-alias, wrong-import-position.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@feanil feanil marked this pull request as ready for review April 3, 2026 20:57
@feanil feanil changed the title feanil/fix isort build: replace isort with ruff I rules Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants